﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Ryland.Utility;

namespace WinformPratice
{
    public partial class DownLoad : Form
    {
        public DownLoad()
        {
            InitializeComponent();
            //dgv.AutoGenerateColumns = false;//是否自动创建列
            dgv.AllowUserToAddRows = false;//是否允许添加行(默认：true)
            dgv.AllowUserToDeleteRows = false;//是否允许删除行(默认：true)
           // dgv.AllowUserToResizeColumns = false;//是否允许调整大小(默认：true)
            //dgv.AllowUserToResizeRows = false;//是否允许调整行大小(默认：true)
        //    dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;//列宽模式(当前填充)(默认：DataGridViewAutoSizeColumnsMode.None)
            //dgv.BackgroundColor = System.Drawing.Color.White;//背景色(默认：ControlDark)
            dgv.BorderStyle = BorderStyle.Fixed3D;//边框样式(默认：BorderStyle.FixedSingle)
            //dgv.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;//单元格边框样式(默认：DataGridViewCellBorderStyle.Single)
            //dgv.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;//列表头样式(默认：DataGridViewHeaderBorderStyle.Single)
            //dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;//是否允许调整列大小(默认：DataGridViewColumnHeadersHeightSizeMode.EnableResizing)
            //dgv.ColumnHeadersHeight = 30;//列表头高度(默认：20)
            //dgv.RowTemplate.Height = 40;
            //dgv.RowsDefaultCellStyle.Font = new Font("宋体", 10, FontStyle.Regular);
            //dgv.RowsDefaultCellStyle.ForeColor = Color.Black;
            //dgv.Cursor = Cursors.Hand;
           dgv.MultiSelect = false;//是否支持多选(默认：true)
            dgv.ReadOnly = true;//是否只读(默认：false)
            dgv.RowHeadersVisible = false;//行头是否显示(默认：true)
           dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;//选择模式(默认：DataGridViewSelectionMode.CellSelect)
           // dgv.Dock = DockStyle.Fill;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string file = textBox1.Text;

            DataTable datatable = CsvHelper.OpenCSV(file, 3);
            dgv.DataSource = datatable;

            //DataGridViewCheckBoxColumn newColumn = new DataGridViewCheckBoxColumn();
            //newColumn.Width = 40;
            //dgv.Columns.Insert(0, newColumn);
        }
    }
}
